<?php 

class Seans{


	public function __construction(){


	}
	public function addSeans($tytu){
		global $sql;
		if($sql->query('INSERT INTO `')){
		
		}
	}
	public function pobierzNajblizsze($limit=10){
		global $sql;
		$data = $sql->QueryGetFetch('SELECT * 
			FROM  `seans` 
			LEFT JOIN  `film` ON  `seans`.`id_film` =  `film`.`id_film` 
			WHERE  `seans`.`termin` >= CURRENT_DATE( ) 
			GROUP BY  `seans`.`id_film` 
			LIMIT 0 , '.$limit.'');
		return $data;
	}
	
	public function pobierzFilm($id){
		global $sql;
		$data = $sql->QueryGetFetch('SELECT *
			FROM `film`
			LEFT JOIN `seans` ON `seans`.`id_film` = `film`.`id_film`
			WHERE `film`.`id_film`="'.$id.'"
		');
		return $data;
	}
	public function pobierzWszystkieFilmy(){
		global $sql;
		$data = $sql->QueryGetFetch('SELECT *,
			(SELECT COUNT(*) FROM `seans` 
				WHERE `seans`.`id_film`=`film`.`id_film` 
				AND `seans`.`termin` >= CURRENT_DATE()
			) AS `ilosc_otwartych_repertaur` 
			FROM `film` 
			ORDER BY `tytul` ASC');
		return $data;
	}
}



?>